package com.jiang.daily.Q1963;

/**
 * @author Jiang
 * @version 1.0
 * @date 2025/03/17 20:37
 */
class Solution {
    public int minSwaps(String s) {
        int cnt = 0, minCnt = 0;
        for (char c: s.toCharArray()) {
            if (c == ']') {
                cnt--;
                minCnt = Math.min(cnt, minCnt);
            } else {
                cnt++;
            }
        }
        return (-minCnt + 1) / 2;
    }
}
